// pages/person/LookingForBooks/Function1.js
var config = require('../../../config');
var app = getApp();

Page({

  /**
   * 页面的初始数据
   */
	data: {
		openId: null,
		userInfo: null,
		logged: null,
		books: {},
		status: "确认完成"
	},

	delete1: function (e) {
		var _this = this;
		var name = e.target.id;
		wx.request({
			url: `${config.service.host}/weapp/Delete`,
			data: {
				type: 1,
				name: name,
				openId: _this.data.openId
			},
			method: "GET",
			header: {
				"Content-Type": "application/json"
			},
			success: function (e) {
				if (e.data == "success") {
					wx.showToast({
						title: '完成',
						icon: 'success',
						mask: true
					});
          wx.request({
            url: `${config.service.host}/weapp/Order`,
            data: {
              type: 1,
              openId: _this.data.openId
            },
            method: "GET",
            header: {
              "Content-Type": "application/json"
            },
            success: function (e) {
              _this.setData({ books: e.data })
            }
          })
				}
			}
		})

	},

	confirm: function (e) {
		var _this = this;
		var name = e.target.id;
		wx.request({
			url: `${config.service.host}/weapp/Confirm`,
			data: {
				type: 1,
				name: name,
				openId: _this.data.openId
			},
			method: "GET",
			header: {
				"Content-Type": "application/json"
			},
			success: function (e) {
				if (e.data == "success") {
					wx.showToast({
						title: '完成',
						icon: 'success',
						mask: true
					})
          wx.request({
            url: `${config.service.host}/weapp/Order`,
            data: {
              type: 1,
              openId: _this.data.openId
            },
            method: "GET",
            header: {
              "Content-Type": "application/json"
            },
            success: function (e) {
              _this.setData({ books: e.data })
            }
          })
						
				}
			}
		})
	},

  /**
   * 生命周期函数--监听页面显示
   */
	onShow: function () {
		var _this = this;
		wx.request({
			url: `${config.service.host}/weapp/Order`,
			data: {
				type: 1,
				openId: _this.data.openId
			},
			method: "GET",
			header: {
				"Content-Type": "application/json"
			},
			success: function (e) {
				_this.setData({ books: e.data })
			}
		})
	},

  /**
   * 生命周期函数--监听页面加载
   */
	onLoad: function (options) {
		this.setData({
			openId: app.globalData.openid,
			userInfo: app.globalData.userInfo,
			logged: app.globalData.logged
		});
	},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
	onReady: function () {

	},

  /**
   * 生命周期函数--监听页面隐藏
   */
	onHide: function () {

	},

  /**
   * 生命周期函数--监听页面卸载
   */
	onUnload: function () {

	},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
	onPullDownRefresh: function () {

	},

  /**
   * 页面上拉触底事件的处理函数
   */
	onReachBottom: function () {

	},

  /**
   * 用户点击右上角分享
   */
	onShareAppMessage: function () {

	}
})